#!/bin/bash
echo -e "\033[32m更新系统\033[0m"
sudo apt update
sudo apt upgrade
rm -rf esp-ai
mkdir esp-ai
cd esp-ai
curl -o main.sh --silent --show-error --fail --location https://gitee.com/zhuxiaohuaqn/ESP-AI-CLI/raw/master/main.sh && chmod +x main.sh
curl -o install_esp-ai.sh --silent --show-error --fail --location https://gitee.com/zhuxiaohuaqn/ESP-AI-CLI/raw/master/install_esp-ai.sh && chmod +x install_esp-ai.sh
curl -o docker.sh --silent --show-error --fail --location https://gitee.com/zhuxiaohuaqn/ESP-AI-CLI/raw/master/docker.sh && chmod +x docker.sh
source ./main.sh
source ./install_esp-ai.sh
source ./docker.sh
# 初始化
print_ascii_art
print_version
print_run_count
print_info




main() {

    echo -e "\033[33m请选择操作:\033[0m"
    echo ""
    echo -e "   ★ 1. 安装 ESP-AI"
    echo ""
    echo -e "   ★ 2. 高级选项"
    echo ""
    read -p "请输入选项：" choice
    case $choice in
        1)

            # 配置ESP-AI
            get_xfyun_params
            # 写入配置文件
            create_index_js
            # 检测docker并安装
            install_docker
            configure_docker_mirror
            # 拉取镜像
            pull_image
            remove_container
            start_container


            
            ;;
        2)
            echo -e "\033[31m维护中\033[0m"
            ;;
        *)
            echo -e "\033[31m无效的选项。\033[0m"
            ;;
    esac
}

main